import { defineStore } from 'pinia'
export const useOrderStoreMap = defineStore('OrderStore', {
  actions: {
    SET_ORDER_MAP(Payload: Map<string, boolean>) {
      this.orderMap = Payload
    },
    SET_ORDER_MAP_Item(orderNo: string, val: boolean) {
      this.orderMap.set(orderNo, val)
      this.isAll = Array.from(this.orderMap.values()).every((item) => item)
    },
    SET_ORDER_MAP_All(val: boolean) {
      for (const iterator of this.orderMap) {
        this.SET_ORDER_MAP_Item(iterator[0], val)
      }
    },
    REMOVE_ORDER_MAP() {
      this.isAll = false
      this.orderMap = new Map()
    },
  },
  state() {
    return {
      isAll: false,
      orderMap: new Map(),
    }
  },
})
